package group2assignone.dao;

import group2assignone.model.*;
import group2assignone.model.Customer;
import group2assignone.model.Flight;
import group2assignone.model.Manager;
import group2assignone.model.Person;
import java.util.ArrayList;

/**
 *
 * @author Group 2
 *
 * Class MySqlComms:
 * A Singleton class which handles all communications to the MySQL database.
 * connects with
 *  userName = "3120S109g02";
 * password = "cc03086abb";
 * and the  url = "jdbc:mysql://dunk.it.jcu.edu.au:3306/3120S109g02";
 *
 * within this class persons, flights and bookings can be added, deleted, edited and found.
 *
 *
 */
public interface MyDAO {

    /**
     * Returns an array of Flights for DUMMY data. (Used when database connection
     * is down)
     * @return
     */
    public ArrayList<Flight> getDummyFlights();

    /**
     * Returns a boolean indicating whether the database is still connected.
     * @return
     */
    public boolean isConnected();

    /**
     * public boolean sQLAddCustomer(Customer c)
     * this function adds a new customer to the database tabel called "Customer"
     * it recieves a paramater customer and returns a boolean reult to notify if it wass added correctly
     * @param c
     * customer paramater input
     * @return
     * boolean result if worked or not
     * return true for worked
     * return false for failed
     */
    public boolean sQLAddCustomer(Customer c);

    /**
     * public boolean sQLAddManager(Manager m)
     * this function adds a new manager to the database tabel called "Manager"
     * it recieves a paramater customer and returns a boolean reult to notify if it wass added correctly
     * @param m
     * Manager paramater input
     * @return
     * boolean result if worked or not
     * return true for worked
     * return false for failed
     */
    public boolean sQLAddManager(Manager m);

    /**
     * Adds a promotion to the flight specified by the parameter flt to the
     * database.
     * @param f 
     * @return
     */
    public boolean sQLAddPromotion(Flight f);

    /**
     * public boolean sQLDeleteCustomer(String userName)
     * This function deletes a customer from the database table "Customer"
     * it receives a String user input 'userName'  and deletes the user with that matching paramater
     * @param userName
     * @return
     * returns a boolean result
     * true if deleted
     * false if failed to delete
     */
    public boolean sQLDeleteCustomer(String userName);

    /**
     * public boolean sQLDeleteManager(String userName)
     * This function deletes a customer from the database table "Manager"
     * it receives a String user input 'userName'  and deletes the user with that matching paramater
     * @param userName
     * @return
     * returns a boolean result
     * true if deleted
     * false if failed to delete
     */
    public boolean sQLDeleteManager(String userName);

    /**
     * This function, public ArrayList<Manager> sQLGetAllFromManager()
     * searches and returns all existing managers from the table manager
     * @return
     * an arrayList of Manager Objects
     */
    public ArrayList<Manager> sQLGetAllFromManager();

    /**
     * public boolean sQLEditCustomer(Customer c, String uNameOld)
     * this function edits an existing customer
     * it recieves an object customer, which contains the updated data, and the old usernumber
     * this is to keep track of the existing if the username was changed
     * @param c
     * Customer object recieved with edited data
     * @param uNameOld
     * the old username, this is used to find the object to be updated
     * @return
     * returns a boolean result:
     * true = edites ok
     * false = edit failed
     */
    public boolean sQLEditCustomer(Customer c, String uNameOld);

    /**
     *  public boolean sQLEditManager(Manager m, String uNameOld)
     * this function edits an existing Manager
     * it recieves an object customer, which contains the updated data, and the old usernumber
     * this is to keep track of the existing if the username was changed
     * @param m
     * Manager object recieved with edited data
     * @param uNameOld
     * the old username, this is used to find the object to be updated
     * @return
     * returns a boolean result:
     * true = edites ok
     * false = edit failed
     */
    public boolean sQLEditManager(Manager m, String uNameOld);

    /**
     * public Customer sQLGetCustomer(String uName)
     * This function attempts to retrieve a Cusomer from the customer table
     * the object customer is returned.
     * @param uName
     * the username is received for the object to find
     * @return
     * retunrs the object found
     */
    public Customer sQLGetCustomer(String uName);

    /**
     * public Manager sQLGetManager(String uName)
     * This function attempts to retrieve a Manager from the manager table
     * the object customer is returned.
     * @param uName
     * the username is received for the object to find
     * @return
     * retunrs the object found
     */
    public Manager sQLGetManager(String uName);

    /**
     * public Person sQLFindPerson(String uName)
     * This function searches through all tables for a given username
     * it returns an object person if there is a match
     * @param uName
     * the recieved username to find
     * @return
     * returns an object of person if it was found
     */
    public Person sQLFindPerson(String uName);

    /**
     * public void sQLCreateFlight(Flight flt)
     * this function adds a new flight to the database
     * it uses all info saved to the paramater Flight recieved
     * @param flt
     * this recieved paramater is an object of Flight. it contains all
     * data for the new flight
     * @return
     * returns the boolean result.
     * true if flight created
     * false if failed to add new flight
     *
     */
    public boolean sQLCreateFlight(Flight flt);

    /**
     * public void sQLEditFlight(Flight flt, String flightNumOld)
     * this function edits an existing flight. it recieves an object of the new
     * Edited flight and a String containing the old flight num, in case it was changed
     * @param flt
     * this recieved paramater contains the detais of the edited flight
     * @param flightNumOld
     * this recieved string holds the old flight number so the system can find it in the table to edit
     * @return
     * returns a boolean result
     * true = edit flight ok
     * false = failed to edit flight
     */
    abstract public boolean sQLEditFlight(Flight flt, String flightNumOld);

    /**
     *  public void sQLDeleteFlight(String flightNum)
     * this function deletes a selected flight. it recieves the corresponding
     * flight number, searches for it in the table and deletes it if it finds it
     * @param flightNum
     * this recieved flight number string gives the ID for the flight to be deleted
     * the flight is deleted if it is found
     *
     * @return
     * retuns a boolean result
     * true = flight deleted
     * false = failed to delete, likely to be from conenction error
     */
    public boolean sQLDeleteFlight(String flightNum);

    /**
     * returns the salesreport generated by the function sQLGenerateSalesReport.
     * @return
     */
    public ArrayList<SaleReport> sQLGetSalesReport();

    /**
     * Makes a booking and stores details in the database.  Booking made depending
     * one the parameters ticket, bookingNum and itemNumber.
     * @param t
     * @param bookingNum
     * @param itemNumber
     * @return
     */
    public boolean sQLMakeBooking(Ticket t, int bookingNum, int itemNumber);

    /**
     * public ArrayList<Flight> sQLSearchFlights(Flight flt)
     * this function is used to find and return an arraylist of flights with similar
     * data. the function recieves an object of Flight containing departure location,
     * arrival location and date. it then searches the flight databse and returns all flights where these three
     * paramaters match
     * @param flt
     * this is the recieved paramater Flight object with the data to be matched
     * @return
     * retuns a arrayList of flights which match.
     * returns null if no matches
     */
    public ArrayList<Flight> sQLSearchFlights(Flight flt);

    /**
     * public boolean sQLCustomerExists(Customer cust)
     * this function checks if a particular customer exists in the database
     * this function may be used for authentication
     *
     * @param cust
     * paramater cust is an object of Customer who's username and password are
     * compared to against the database.
     * @return
     * returns a boolean result detemining if it exists in the database
     * true = username and password correct -> customer is valid
     * false = username or password do not match
     */
    public boolean sQLCustomerExists(Customer cust);

    /**
     * public boolean sQLManagerExists(Manager man)
     * this function checks if a particular manager exists in the database
     * this function may be used for authentication
     *
     * @param man
     * paramater man is an object of Manager who's username and password are
     * compared to against the database.
     * @return
     * returns a boolean result detemining if it exists in the database
     * true = username and password correct -> manager is valid
     * false = username or password do not match
     */
    public boolean sQLManagerExists(Manager man);

    /**
     * Returns a flight from the database by searching for the flight number.
     *
     * @param fnum
     * @return
     */
    public Flight sQLGetFlight(String fnum);

    /**
     * This function, public ArrayList<Flight> getFlights()
     * searches and returns all existing flights from the table Flight
     * @return
     * an arrayList of flight Objects
     */
    public ArrayList<Flight> getFlights();

    /**
     * This function adds the airport which has been passed to it, to the database.
     * @param airport
     * @return
     */
    public boolean sQLAddAirport(Airport airport);

    /**
     * Returns an array of all the airports in the database.
     * @return
     */
    public ArrayList<Airport> sQLGetAirports();

    /**
     * Updating an airport found in the database.  Airport is found by the primary
     * key (airport location) and is replaced with the new values in the airport parameter ap.
     * @param ap
     * @param airportLocOld
     * @return
     */
    public boolean sQLEditAirport(Airport ap, String airportLocOld);

    /**
     * Deletes the airport specified by the parameter airportLoc from the database.
     * @param airportLoc
     * @return
     */
    public boolean sQLDeleteAirport(String airportLoc);

    /**
     * Generates a sales report from information in the database.  Returns a
     * boolean value indicating whether the report was successful or not.
     * @return
     */
    public boolean sQLGenerateSalesReport();

    /**
     * Returns the booking number of the previously made booking.
     * @return
     */
    public int sQLGetLastBookingNumber();

    /**
     * Returns the airport tax from the airport specified in the parameter airportLoc
     * @param airportLoc
     * @return
     */
    public double sQLGetAirportTax(String airportLoc);

    /**
     * Returns the number of available seats in the flight specified by the
     * parameter flightnum.
     * @param flightNum
     * @return
     */
    public int sQLGetSeatsAvailable(String flightNum);
}





